home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 6.1 KB | 221 lines | [TEXT/MPS ] |
- //----------------------------------------------------------------------------------------
- // UPerform.cp
- // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
- //----------------------------------------------------------------------------------------
-
- #ifndef __UPERFORM__
- #include "UPerform.h"
- #endif
-
- // MacApp
-
- #ifndef __UDIALOG__
- #include "UDialog.h"
- #endif
-
- #ifndef __UFILE__
- #include "UFile.h"
- #endif
-
- #ifndef __UCOREGLOBALS__
- #include "UCoreGlobals.h"
- #endif
-
- #ifndef __UCOREUTILITIES__
- #include "UCoreUtilities.h"
- #endif
-
- #ifndef __UMEMORY__
- #include "UMemory.h"
- #endif
-
- // #ifndef __USEGMENTS__
- // #include "USegments.h"
- // #endif
-
- #ifndef __UWINDOW__
- #include "UWindow.h"
- #endif
-
- // Toolbox
-
- // ANSI
-
- #ifndef __STDIO__
- #include <stdio.h>
- #endif
-
- // Apple Specials
-
- #if qPerform
- #ifndef __PERF__
- #include "Perf.h"
- #endif
- #endif
-
- //----------------------------------------------------------------------------------------
- // Static variable definitions.
- //----------------------------------------------------------------------------------------
-
- #if qPerform
-
- static TP2PerfGlobals pTP2PerfGlobals; // Pointer to performance globals record
- // Non-NULL if tools are inited
-
- static Boolean pPerfMonitorEnabled; // Is the performance monitor enabled or
- // disabled.
- #endif
-
- //========================================================================================
- // GLOBAL Procedures
- //========================================================================================
- #undef Inherited
-
- #if qPerform
-
- //----------------------------------------------------------------------------------------
- // PerfMonitorInitiated: Are we currently doing performance monitoring.
- //----------------------------------------------------------------------------------------
- #pragma segment MADebugger
-
- Boolean PerfMonitorInitiated()
- {
- return pTP2PerfGlobals != NULL;
- } // PerfMonitorInitiated
-
-
- //----------------------------------------------------------------------------------------
- // InitiatePerfMonitor: Initiate performance monitoring from the initialize performance
- // monitor dialog box.
- //----------------------------------------------------------------------------------------
- #pragma segment MADebugger
-
- void InitiatePerfMonitor(TWindow* aWindow)
- {
- #if !qPowerPC
- Boolean aBool;
-
- short timerCount = (short) ((TNumberText *) aWindow->FindSubView('tmct'))->GetValue();
- short codeAndROMBucketSize = (short) ((TNumberText *) aWindow->FindSubView('cbsz'))->GetValue();
- Boolean doROM = ((TCheckBox *) aWindow->FindSubView('mrcd'))->IsOn();
- Boolean doAppCode = ((TCheckBox *) aWindow->FindSubView('macd'))->IsOn();
- CStr255 appCodeType;
- ((TEditText *) aWindow->FindSubView('acrs'))->GetText(appCodeType);
- short romID = (short) ((TNumberText *) aWindow->FindSubView('rmid'))->GetValue();
- CStr255 romName;
- ((TEditText *) aWindow->FindSubView('rmnm'))->GetText(romName);
- Boolean doRAM = ((TCheckBox *) aWindow->FindSubView('mout'))->IsOn();
- long ramLow = ((TNumberText *) aWindow->FindSubView('from'))->GetValue();
- long ramHigh = ((TNumberText *) aWindow->FindSubView('to '))->GetValue();
- short ramBucketSize = (short) ((TNumberText *) aWindow->FindSubView('otsz'))->GetValue();
-
- aBool = InitPerf(&pTP2PerfGlobals, timerCount, codeAndROMBucketSize, doROM, doAppCode,
- appCodeType, romID, romName, doRAM, ramLow, ramHigh, ramBucketSize);
-
- if (!aBool)
- pTP2PerfGlobals = NULL;
- else
- EnablePerfMonitor(TRUE);
- #else
- pTP2PerfGlobals = NULL;
- #endif
- } // InitiatePerfMonitor
-
-
- //----------------------------------------------------------------------------------------
- // DumpPerfMonitor:
- //----------------------------------------------------------------------------------------
- void DumpPerfMonitor(const FSSpec& fileSpec)
- {
- #if !qPowerPC
- if (pTP2PerfGlobals)
- {
- CStr255 pathName;
-
- // Create a TFile to get the pathname.
-
- TFile* aFile = new TFile;
- aFile->IFile('TEXT', 'MPS ', kUsesDataFork, noResourceFork, kDataOpen, !kRsrcOpen);
- aFile->Specify(fileSpec);
- aFile->GetPathName(pathName);
-
- PerfDump(pTP2PerfGlobals, pathName + (const CStr255&) fileSpec.name, TRUE, 80);
-
- delete aFile;
- }
- #endif
- } // DumpPerfMonitor
-
-
- //----------------------------------------------------------------------------------------
- // EnablePerfMonitor: Enable or disable performance monitoring, assuming already its
- // initiated.
- //----------------------------------------------------------------------------------------
- #pragma segment MADebugger
-
- void EnablePerfMonitor(const Boolean enable)
- {
- #if !qPowerPC
- if (pTP2PerfGlobals && enable != pPerfMonitorEnabled)
- {
- PerfControl(pTP2PerfGlobals, enable);
- pPerfMonitorEnabled = enable;
- }
- #endif
- } // EnablePerfMonitor
-
-
- //----------------------------------------------------------------------------------------
- // PerfMonitorEnabled: Is the performance monitor enabled?
- //----------------------------------------------------------------------------------------
- #pragma segment MADebugger
-
- Boolean PerfMonitorEnabled()
- {
- return pPerfMonitorEnabled;
- } // PerfMonitorEnabled
-
-
- //----------------------------------------------------------------------------------------
- // TerminatePerfMonitor: Shut down the performance monitoring tools.
- //----------------------------------------------------------------------------------------
- #pragma segment MADebugger
-
- void TerminatePerfMonitor()
- {
- #if !qPowerPC
- if (pTP2PerfGlobals)
- {
- TermPerf(pTP2PerfGlobals);
- pTP2PerfGlobals = NULL;
- }
- #else
- pTP2PerfGlobals = NULL;
- #endif
- } // TerminatePerfMonitor
-
- #endif // qPerform
-
- //----------------------------------------------------------------------------------------
- // DebugTerminate:
- //----------------------------------------------------------------------------------------
- #pragma segment MADebugger
-
- #if qDebug
-
- void DebugTerminate()
- {
- #if qPerform
- // Make sure the performance tools are shut down if they are initialized
- if (pTP2PerfGlobals)
- TerminatePerfMonitor();
- #endif
- } // DebugTerminate
-
- #endif // qDebug
-
- //----------------------------------------------------------------------------------------
- // End of UPerform.cp
-
- #pragma segment Inline
-